import type { PageParams, PageResult } from '@/types/global'
import type {
  goodsListItem,
  goodsListParams,
  goodsResult,
  goodsServiceItem,
  goodsShareResult,
} from '@/types/goods'
import { request } from '@/utils/request'

export const getGoodsListApi = (data?: PageParams & goodsListParams) => {
  return request<PageResult<goodsListItem>>({
    method: 'GET',
    url: '/goods',
    data,
  })
}

export const getGoodsByIdApi = (id: number) => {
  return request<goodsResult>({
    method: 'GET',
    url: '/goods/detail',
    data: {
      id,
    },
  })
}

export const getGoodsServiceApi = (service_ids: string) => {
  return request<goodsServiceItem[]>({
    method: 'GET',
    url: '/goods/service',
    data: {
      service_ids,
    },
  })
}

export const getShareInfoApi = (id: number) => {
  return request<goodsShareResult>({
    method: 'GET',
    url: '/goods/share',
    data: {
      id,
    },
  })
}
